﻿using UnityEngine;
using UnityEngine.UIElements;
using winS.UnityEditor.UIElement;

namespace winS.UnityEditor.ProcessEditor
{
    public abstract class GraphElement : VisualElement
    {
        public virtual bool muted { get; protected set; }
        public virtual bool selected { get; protected set; }

        public virtual bool movable => true;
        public virtual bool muteable => true;
        public virtual bool copyable => true;
        public virtual bool deletable => true;
        public virtual bool selectable => true;

        /// <summary>
        /// 元素的尺寸
        /// </summary>
        public Vector2 size => layout.size;
        /// <summary>
        /// 元素的位置
        /// </summary>
        public virtual Vector2 position { get => this.GetPosition();  set => this.SetPosition(value); }

        /// <summary>
        /// 元素所在的节点视图
        /// </summary>
        public StepGraphView stepGraphView { get; internal set; }

        public void Mute()
        {
            muted = true;
            OnMute();
        }
        public void Unmute()
        {
            muted = false;
            OnUnmute();
        }
        public void Select()
        {
            selected = true;
            OnSelected();
        }
        public void Unselect()
        {
            selected = false;
            OnUnselected();
        }

        protected internal virtual void OnMute()
        {
        }
        protected internal virtual void OnUnmute()
        {
        }
        protected internal virtual void OnSelected()
        {
        }
        protected internal virtual void OnUnselected()
        {
        }
    }
}